﻿using Microsoft.Graphics.Canvas.Effects;
using Microsoft.Graphics.Canvas.UI.Xaml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using 纸片人.win2dEffectControl.DataClass;

// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235

namespace 纸片人.win2dEffectControl
{
    public sealed class DisplayEffectControl : EffectControl
    {
        public DisplayEffectControl()
        {
            this.DefaultStyleKey = typeof(DisplayEffectControl);
            EffectData = OneEffetData = new DisplayEffectData();
        }

        public override EffectOneSourceData OneEffetData { get; set; }
        protected override void OnApplyTemplate()
        {
 
            controlContainer = GetTemplateChildFormName<Panel>(nameof(controlContainer));
            if (controlContainer == null)
            {
                return;
            }
            SetproviderDropControlElement();
            canvas = GetTemplateChildFormName<CanvasControl>("canvas");
            timer.Interval = TimeSpan.FromMilliseconds(16);
            timer.Tick += Timer_Tick;
            timer.Start();
            canvas.Draw += Canvas_Draw;
            canvas.Unloaded += Canvas_Unloaded;
        }

    }
}
